<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h3>6. 设计一个程序，它（使用一个数组）接收用户输入的7门课程的成绩，然后在页面上显示其总成绩和平均分，并列出小于60的成绩。</h3>
    <script>
        /*  var scores = [],
            result = '',
            average = 0,
            sum = 0;
        for (var i = 0; i < 7; i++) {
            var score = parseInt(prompt('请输入你的第' + i + '门成绩'));
            scores.push(score);

        }
        // console.log(scores);
        for (var i = 0; i < 7; i++) {
            if (scores[i] <= 60) {
                result += scores[i] + ','
            }
            sum += scores[i];
        }
        average = sum / scores.length;

        document.write('总成绩：' + sum + '<br>');
        document.write('平均分：' + average + '<br>');
        document.write('以下为不合格成绩：' + result); */


        // 方案二
        var result = '',
            average = 0,
            sum = 0;
        for (var i = 0; i < 7; i++) {
            var score = parseInt(prompt('请输入你的第' + (i + 1) + '门成绩'));
            sum += score;
            if (score <= 60) {
                result += score + ','
            }
        }
        average = sum / 7;

        document.write('总成绩：' + sum + '<br>');
        document.write('平均分：' + average + '<br>');
        document.write('以下为不合格成绩：' + result);
    </script>
</body>

</html>